package dto;

// Generated May 6, 2011 4:19:20 PM by Hibernate Tools 3.3.0.GA

import SessionFactory.SessionFactoryUtil;
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import static org.hibernate.criterion.Example.create;

/**
 * Home object for domain model class Filteredposts.
 * @see dto.Filteredposts
 * @author Hibernate Tools
 */
public class FilteredpostsHome {

	private static final Log log = LogFactory.getLog(FilteredpostsHome.class);

	private final SessionFactory sessionFactory = SessionFactoryUtil.getInstance();


	public void persist(Filteredposts transientInstance) {
		log.debug("persisting Filteredposts instance");
		try {
			sessionFactory.getCurrentSession().persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void attachDirty(Filteredposts instance) {
		log.debug("attaching dirty Filteredposts instance");
		try {
			sessionFactory.getCurrentSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Filteredposts instance) {
		log.debug("attaching clean Filteredposts instance");
		try {
			sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void delete(Filteredposts persistentInstance) {
		log.debug("deleting Filteredposts instance");
		try {
			sessionFactory.getCurrentSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Filteredposts merge(Filteredposts detachedInstance) {
		log.debug("merging Filteredposts instance");
		try {
			Filteredposts result = (Filteredposts) sessionFactory
					.getCurrentSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Filteredposts findById(Integer id) {
		log.debug("getting Filteredposts instance with id: " + id);
		try {
			Filteredposts instance = (Filteredposts) sessionFactory
					.getCurrentSession().get("dto.Filteredposts", id);
			if (instance == null) {
				log.debug("get successful, no instance found");
			} else {
				log.debug("get successful, instance found");
			}
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List<Filteredposts> findByExample(Filteredposts instance) {
		log.debug("finding Filteredposts instance by example");
		try {
			List<Filteredposts> results = (List<Filteredposts>) sessionFactory
					.getCurrentSession().createCriteria("dto.Filteredposts")
					.add(create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
}
